package org.easiermock;

import org.junit.Assert;

public class EasierMockListenerTest extends AbstractEasierMockTest {
	
	protected <T extends TestInterface> void testStubBehaviour(Class<T> classToStub, Stub stub) {
		DefaultMockContext mockContext = new DefaultMockContext();
		CountingMethodListener countingMethodListener = new CountingMethodListener();
		mockContext.addMethodListener(countingMethodListener);
		
		TestInterface toStub = EasierMock.createMock(classToStub, stub, mockContext);
		toStub.method1();
		Assert.assertEquals(1, countingMethodListener.getBeforeCount("method1"));
		toStub.method1();
		Assert.assertEquals(2, countingMethodListener.getBeforeCount("method1"));
	}
	
}
